package com.phantasy.loaders.gameLoader
{
	import flash.utils.ByteArray;

	/**
	 *资源描述对象 
	 * @author Liseen
	 * 
	 */	
	public class ResourceItem
	{
		public static const SWF:String = "swf";
		public static const FILE:String = "file";
		public static const IMAGE:String = "image";
		public static const PRIORITY_1:int = 1;
		public static const PRIORITY_2:int = 2;
		public static const PRIORITY_3:int = 3;

		
		public var data:Object;
		public var handler:Function;
		public var processHandler:Function;
		public var errorHandler:Function;
		public var url:String;
		public var priority:int;
		public var loading:Boolean = false;
		public var content:ByteArray;
		public var isNeedSave:Boolean = false;
		
		public function ResourceItem()
		{
		}
		/**
		 *获取资源对象的文件类型 
		 * @return 
		 * 
		 */		
		public function get type():String
		{
			var suffix:String = this.url.substr((this.url.lastIndexOf(".") + 1), (this.url.length - this.url.lastIndexOf(".")));
			suffix = suffix.toLowerCase();
			if ( suffix == SWF)
			{
				return SWF;
			}
			if ((suffix == "xml") || (suffix == "txt") || (suffix == "lib") || (suffix == "mcms"))
			{
				return FILE;
			}
			if ((suffix == "png") || (suffix == "jpg"))
			{
				return IMAGE;
			}
			throw new Error("非法文件类型！");
		}
	}
}